<template>
  <section id="announcement">
    <div class="title clearfix">
      <div class="pull_left">公告</div>
      <div @click="$router.push('/announcement')" class="more pull_right">
        <a href="javascript:;">更多</a>
        <img src="../assets/image/more.png" alt width="7" height="11">
      </div>
    </div>

    <ul class="content" ref="announcement">
      <li v-for="item in pnoTiceList" class="clearfix" @click="toDetail(item)">
        <div class="pull_left">{{item.title}}</div>
        <div class="pull_right">{{item.time}}</div>
      </li>
    </ul>
    <span v-show="false">{{upelHeig}}</span>
  </section>
</template>
<script>
import { _getPNoticeList } from "../axios/index.js";
export default {
  data() {
    return {
      pnoTiceList: null
    };
  },
  created() {
    this.getPNoticeList();
  },
  computed: {
    upelHeig() {
      const $store = this.$store.state;
      if ($store.announcemState) {
        this.$nextTick(() => {
          this.$refs.announcement.style = "height:336px";
        });
        return true;
      } else {
        this.$nextTick(() => {
          this.$refs.announcement.style = "height:266px";
        });
        return false;
      }
    }
  },
  methods: {
    toDetail(item) {
      localStorage.setItem("curNotice", JSON.stringify(item));
      this.$router.push("/noticeDetail/" + item.id);
    },
    async getPNoticeList() {
      let res = await _getPNoticeList(1, 8);
      if (res.data.code == 200) {
        let data = res.data.data.data;
        for (let i = 0; i < data.length; i++) {
     

          data[i].time = this.$js
            .timeToDate(data[i].create_time)
            .slice(0, 10);
        }
        this.pnoTiceList = data;
      }
    }
  }
};
</script>
